package com.example.esquel_carpool.app;

import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;
import android.widget.ImageView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.example.esquel_carpool.R;
import com.example.esquel_carpool.utils.ImageLoaderUtil;
import com.lzy.ninegrid.NineGridView;

public class MApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        NineGridView.setImageLoader(new GlideImageLoader());
    }

    private class GlideImageLoader implements NineGridView.ImageLoader {
        private RequestOptions mArg1;

        public GlideImageLoader() {
            mArg1 = new RequestOptions()
                    .fitCenter()
                    .error(R.drawable.ic_default_image)
                    .placeholder(R.drawable.ic_default_image)
                    .diskCacheStrategy(DiskCacheStrategy.ALL);
        }

        @Override
        public void onDisplayImage(Context context, ImageView imageView, String url) {
            ImageLoaderUtil.getInstance().displayImage(imageView,url,mArg1);

        }

        @Override
        public Bitmap getCacheImage(String url) {
            return null;
        }
    }
}
